#ifndef __SERVER_H__
#define __SERVER_H__

#include <string>
#include <map>
#include <ctime>
#include "dataStruct.h"

namespace tally
{

class TallyServer
{
private:
    std::string                 m_addr;
    short                       m_port;
    int                         m_socket;
    std::map<int, ClientInfo>   m_clientArr;

    const int                   m_maxEvents;
    
public:
    TallyServer(std::string addr, short port);
    ~TallyServer();

private:
    TallyServer(const TallyServer&) = delete;               // 禁用拷贝构造
    TallyServer& operator=(const TallyServer&) = delete;    // 禁用赋值运算符

    void setNonBlocking(int socket);

    void messageHandle(int epollFd, int clientFd);
    void userRegist(int clientFd, const char* const d, int len);
    void userLogin(int clientFd, const char* const d, int len);
    void tallyRecord(int clientFd, const char* const d, int len);
};

} // end of namespace

#endif // __SERVER_H__